<template>
  <div class="withDraw" ref="homePage">
    <div class="bj">
      <van-nav-bar title="提现" left-arrow @click-left="onClickLeft" />
    </div>
    <div style="width: 100%;height: 46px;"></div>
    <div v-show="isflag" class="wudingdan">
      <van-icon name="description" />
      <p>亲,暂无相关数据哦</p>
    </div>
    <div class="wdContent">
      <div class="wdTop">
        <p class="balance"> {{totalCount}}<i class="unit">元</i></p>
        <p class="disc">当前账户余额</p>
      </div>
      <!-- wdTop end -->
      <div class="main">
        <p class="way">提现到微信钱包</p>
        <div class="operation">
          <span class="unit">￥</span>
          <div class="inputItem">
            <van-field v-model="money" type="number" placeholder="输入提现金额" />
          </div>
          <van-button class="allBtn" size="small" plain type="primary" @click="allMoney()">全部</van-button>
        </div>
        <!-- <p class="sm">提现需要扣除0%手续费</p> -->
        <!-- <p class="txNum">
          <span class="lb">剩余提现次数：</span>
          <span class="num">2</span>
        </p> -->
      </div>
      <div class="operBtn">
        <van-button type="primary" size="normal" class="txBtn-now" @click="Withdraw()">立即提现</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Withdraw, Income } from '@/api/home.js'
import { getToken } from '@/utils'
export default {
  data () {
    return {
      isflag: false,
      totalCount: 0, // 总收益
      money: ''
    }
  },
  mounted () {
    this.clientHeight = `${document.documentElement.clientHeight}`
    this.$refs.homePage.style.minHeight = this.clientHeight + 'px'
    this.Income()
  },
  methods: {
    onClickLeft () {
      this.$router.go(-1)
    },
    allMoney () {
      this.money = this.totalCount
    },
    Withdraw () {
      // let token = getToken()
      // let amount = this.money
      // let urldata = "http://www.anyiyou.cn/public/program/retail/auto.aspx?utoken="
      // let url = "http://www.anyiyou.cn/view/#/me"
      // if (!this.money == '' && this.money > 0) {
      //   window.location.href = urldata + token + " & amount=" + amount + " & bkurl=" + escape(url)
      // }

       this.$toast({
          message: '提现成功！'
        })

    },
    Income () {
      let data = {}
      Income(data).then(res => {
        console.log(res)
        if (res.code === 0) {
          this.totalCount = res.data.TotalCount
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.withDraw {
  font-size: 14px;
  color: #000;
  .bj {
    .van-icon {
      color: white !important;
    }
  }
  .wdContent {
    padding: 20px;
    .wdTop {
      padding: 30px 0 10px;
      text-align: center;
      .balance {
        font-size: 32px;
        font-weight: 600;
        color: #000;
        padding-bottom: 20px;
        .unit {
          font-size: 14px;
          font-style: normal;
          padding-left: 10px;
          font-weight: normal;
        }
      }
      .disc {
        padding-bottom: 20px;
        color: #818181;
      }
    }
    .main {
      background: #fff;
      padding: 20px;
      width: 100%;
      border-radius: 5px;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
      .way {
        text-align: center;
        padding-bottom: 15px;
        color: #818181;
      }
      .operation {
        display: flex;
        position: relative;
        padding: 20px 0 10px;
        .unit {
          font-size: 16px;
          font-weight: 600;
          vertical-align: middle;
          line-height: 44px;
        }
        .inputItem {
          border-bottom: 1px solid #ccc;
          width: 100%;
          /deep/ .van-field__control {
            color: #000;
            font-size: 16px;
          }
        }
        .allBtn {
          border: 1px solid #2cafab;
          color: #2eb0ac;
          text-align: center;
          position: absolute;
          right: 0;
        }
      }
      .sm {
        padding: 15px 0 0;
      }
      .txNum {
        padding: 15px 0 0;
        font-size: 16px;
        .lb {
          color: #818181;
          font-size: 14px;
        }
      }
    }
    .operBtn {
      padding: 30px 20px;
      text-align: center;
      .txBtn-now {
        width: 100%;
        background: #2cafab;
        border: 1px solid #2cafab;
      }
    }
  }
}
</style>
